import org.junit.Test;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;

/**
 * @author zhoukun 86547462@qq.com
 * @version 1.0
 * @date 2020/11/3 17:44
 */

public class test {
    public static void main(String[] args) {
        int[] arr={1,2,45,56,1};
        int t=0;

        //临时数组
        Object[] xinArr=new Object[arr.length];

        for(int i=0;i<arr.length;i++){
            //声明标记，是否重复
            boolean isRepeat = true;
            for(int j=i+1;j<arr.length;j++){
                //如果有重复元素，将标记置为false
                if(arr[i]==arr[j]){
                    isRepeat = false;
                    break;
                }
            }
            //标记为true表示没有重复元素
            if(isRepeat){
                xinArr[t] = arr[i];
                t++;
            }
        }
        //去重后数组
        Object[] newArr = new Object[t];
        System.arraycopy(xinArr, 0, newArr, 0, t);
        for (Object o : newArr) {
            System.out.println(o);
        }
    }

    @Test
    public void set()
    {
        int[] arr={1,2,45,56,1};
        HashSet set=new HashSet();
        for (int i = 0; i < arr.length; i++) {
            set.add(arr[i]);
        }

        set.forEach(System.out::println);

    }
    @Test
    public void string()
    {
        String str="docker";
        System.out.println(new StringBuilder(str).reverse().toString());
    }

    @Test
    public void sort() {
        int[] array = {1, 65, 23, 56};
        Arrays.sort(array);

        int[] descArray = new int[array.length];
        int j=0;
        for (int i = array.length-1; i >= 0; i--) {
                descArray[j] = array[i];
                j++;
        }
        for (int num : descArray) {
            System.out.println(num);
        }

    }

    @Test
    public void num()
    {
        int[] nums = {1,3,7,8};
        int target = 10;
        int x = 0,y = 0;
        for (int i = 0; i < nums.length; i++) {
            for (int j = i + 1; j < nums.length; j++) {
                if (target==  nums[j] +nums[i]) {
                    x=i;
                    y=j;
                }
            }
        }
        System.out.println(x+","+y);
    }

    @Test
    public void  myMethod() {

        try {
            Integer.parseInt("hello");
        } catch (NumberFormatException e) {
            throw e;
        } finally {
            try {
                int a = 10 / 0;
            } catch (ArithmeticException e) {
                throw e;
            }
        }
    }

    }
